package LuoGu;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class P1449 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Stack<Integer> stack = new Stack<>();
        String input = br.readLine();
        String[] list = input.split("\\.");
        for (String s : list) {
            if (isNum(s)) {
                if (isCal(s)) {
                    for (int i = 0; i < s.length(); i++) {
                        if (s.charAt(i) == '+') {
                            int tmp1 = stack.pop();
                            int tmp2 = stack.pop();
                            stack.add(tmp1 + tmp2);
                        } else if (s.charAt(i) == '-') {
                            int tmp1 = stack.pop();
                            int tmp2 = stack.pop();
                            stack.add(tmp2 - tmp1);
                        } else if (s.charAt(i) == '*') {
                            int tmp1 = stack.pop();
                            int tmp2 = stack.pop();
                            stack.add(tmp2 * tmp1);
                        } else if (s.charAt(i) == '/') {
                            int tmp1 = stack.pop();
                            int tmp2 = stack.pop();
                            stack.add(tmp2 / tmp1);
                        } else if (s.charAt(i) >= '0' && s.charAt(i) <= '9') {
                            stack.add(Integer.parseInt(s.substring(i, s.length())));
                            break;
                        }
                    }
                } else {
                    stack.add(Integer.parseInt(s));
                }
            } else {
                for (int i = 0; i < s.length(); i++) {
                    if (s.charAt(i) == '+') {
                        int tmp1 = stack.pop();
                        int tmp2 = stack.pop();
                        stack.add(tmp1 + tmp2);
                    } else if (s.charAt(i) == '-') {
                        int tmp1 = stack.pop();
                        int tmp2 = stack.pop();
                        stack.add(tmp2 - tmp1);
                    } else if (s.charAt(i) == '*') {
                        int tmp1 = stack.pop();
                        int tmp2 = stack.pop();
                        stack.add(tmp2 * tmp1);
                    } else if (s.charAt(i) == '/') {
                        int tmp1 = stack.pop();
                        int tmp2 = stack.pop();
                        stack.add(tmp2 / tmp1);
                    }
                }
            }
        }
        System.out.print(stack.pop());
    }
    public static boolean isNum(String s){
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i)>='0'&&s.charAt(i)<='9'){
                return true;
            }
        }
        return false;
    }
    public static boolean isCal(String s){
        for (int i = 0; i < s.length(); i++) {
            if(!(s.charAt(i)>='0'&&s.charAt(i)<='9')){
                return true;
            }
        }
        return false;
    }
}
